package com.xiao.controller;


import com.xiao.annotation.SystemLog;
import com.xiao.domain.ResponseResult;
import com.xiao.domain.pojo.BlogSysUser;
import com.xiao.service.BlogSysUserService;
import com.xiao.domain.vo.UserInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@Api(tags = "用户控制层")
public class UserController {
    @Autowired
    BlogSysUserService blogSysUserService;


    @GetMapping("/userInfo")
    @ApiOperation(value = "获取个人信息",notes = "获取个人信息,认证后才能访问" )

    @SystemLog(businessName = "获取用户信息")// 添加 日志注解

    public ResponseResult userInfo(){
        ResponseResult result = blogSysUserService.userInfo();
        return result;
    }

    @PutMapping("/userInfo")
    @ApiOperation(value = "修改个人信息",notes = "修改个人信息,认证后才能访问" )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userInfoVo",value = "userInfoVo-用户信息VO")
    })
    public ResponseResult updateUserInfo(@RequestBody UserInfoVo userInfoVo){
        ResponseResult result = blogSysUserService.updateUserInfo(userInfoVo);
        return result;
    }

    @PostMapping("/register")
    @ApiOperation(value = "注册请求",notes = "注册请求,不需要认证" )
    @ApiImplicitParams({
            @ApiImplicitParam(name = "blogSysUser",value = "用户实体类")
    })
    public ResponseResult register(@RequestBody BlogSysUser blogSysUser){
        ResponseResult result = blogSysUserService.register(blogSysUser);
        return result;
    }
}
